/* 
  Copyright (c) SilverLining 2015
  Date:    2016-1-7
  File:    GameObject.h  
  Description: 

*/

#pragma once

namespace SL
{
	namespace M
	{
		delegate void ReadDelegate(m::archiver* archiver);
		delegate void WriteDelegate(m::archiver* archiver);

		ref class Archiver;

		/// <summary>
		/// Represent the base managed object class, supporting archival.
		/// </summary>
		public ref class GameObject : System::Object
		{
		public:
			GameObject();
			~GameObject();
			!GameObject();

		protected:
			/// <summary>
			/// Implementation of the read method for archival.
			/// </summary>
			/// <param name="archiver">The archiver to read from.</param>
			virtual void Read(Archiver^ archiver);
			/// <summary>
			/// Implementation of the read method for archival.
			/// </summary>
			/// <param name="archiver">The archiver to read from.</param>
			virtual void Read(m::archiver* archiver);
			/// <summary>
			/// Implementation of the write method for archival.
			/// </summary>
			/// <param name="archiver">The archiver to write to.</param>
			virtual void Write(Archiver^ archiver);
			/// <summary>
			/// Implementation of the write method for archival.
			/// </summary>
			/// <param name="archiver">The archiver to write to.</param>
			virtual void Write(m::archiver* archiver);

		internal:
			shim_object* NativePtr;
			ReadDelegate^ _ReadDelegate;
			WriteDelegate^ _WriteDelegate;

		private:
			System::Runtime::InteropServices::GCHandle^ _wGch;
			System::Runtime::InteropServices::GCHandle^ _rGch;
		};
	}
}
